		<div class="message_all_btn br5">
<?php if($countMessages > 3) : ?>
			<a href="#" class="btn yellow br3 ok fl"  id="messages_all"><?php echo Yii::t('main', 'View all messages'); ?></a>
<?php endif ?>
		</div>
<?php if($countMessages > 3) : ?>
		<ul id="dialog_list" class="messages messages_all">
<?php else : ?>
		<ul id="dialog_list" class="messages">
<?php endif ?>
<?php foreach ($messages as $key => $message) : ?>
	<?php if($key == $countMessages-3 && ($countMessages > 3)) : ?>
		</ul>
		<ul id="dialog_list" class="messages">
	<?php endif ?>
	<li class="<?php echo $message['from_id'] == Yii::app()->user->id ? 'outbox' : 'inbox' ?>">
		<div class="date"><?php echo Yii::app()->dateFormatter->format("dd/MM/yyyy H:mm", $message->crdate); ?></div>
		<p class="crnt_dialog <?php echo $message->read == 1 ? 'new': '';  ?>" ><?php echo $message->text; ?></p>
		<div class="av">
			<a href="<?php echo Yii::app()->createUrl('users/view', array('id'=>$message->user_from->id));?>">
				<div class="br5">
					<?php echo $this->material_image($message->user_from->id, $message->user_from->avatar, '58', 'images/' . $message->user_from->id); ?>
				</div>
				<span><?php echo CHtml::encode($message->user_from->full_name); ?></span>
			</a>
		</div>
		<div class="arr"></div>
	</li>
<?php endforeach ?>
</ul>